package com.mayikt.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 余胜军
 * @ClassName CountService
 * @qq 644064779
 * @addres www.mayikt.com
 * 微信:yushengjun644
 */
@RestController
@Slf4j
@Scope(value = "prototype")
public class CountService {

    private int count = 0;

    /**
     * spring 默认 bean 对象都是单例
     * @return
     */
    @RequestMapping("/count")
    public synchronized String count(HttpServletRequest request) {
        try {
            log.info(">count<" + count++);
            Thread.sleep(3000);
        }catch (Exception e){

        }
        return "count";
    }
}
